package com.ktgj.service.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.service.domain.KtserviceViphallAuxtype;
import com.ktgj.service.service.IKtserviceViphallAuxtypeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 贵宾厅设施功能Controller
 * 
 * @author ruoyi
 * @date 2021-09-03
 */
@ControllerAdvice
@RestController
@RequestMapping("/auxtype")
public class KtserviceViphallAuxtypeController extends BaseController
{
    @Autowired
    private IKtserviceViphallAuxtypeService KtserviceViphallAuxtypeService;

    /**
     * 查询贵宾厅设施功能列表
     */
    //@PreAuthorize(hasPermi = "service:auxtype:list")
    @GetMapping("/list")
    public TableDataInfo list(KtserviceViphallAuxtype KtserviceViphallAuxtype)
    {
        startPage();
        List<KtserviceViphallAuxtype> list = KtserviceViphallAuxtypeService.selectKtserviceViphallAuxtypeList(KtserviceViphallAuxtype);
        return getDataTable(list);
    }

    /**
     * 导出贵宾厅设施功能列表
     */
    //@PreAuthorize(hasPermi = "service:auxtype:export")
    @Log(title = "贵宾厅设施功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, KtserviceViphallAuxtype KtserviceViphallAuxtype) throws IOException
    {
        List<KtserviceViphallAuxtype> list = KtserviceViphallAuxtypeService.selectKtserviceViphallAuxtypeList(KtserviceViphallAuxtype);
        ExcelUtil<KtserviceViphallAuxtype> util = new ExcelUtil<KtserviceViphallAuxtype>(KtserviceViphallAuxtype.class);
        util.exportExcel(response, list, "贵宾厅设施功能数据");
    }

    /**
     * 获取贵宾厅设施功能详细信息
     */
    //@PreAuthorize(hasPermi = "service:auxtype:query")
    @PostMapping("/getInfo")
    public AjaxResult getInfo(@RequestBody Map<String, Object> map)
    {
        Long auxtypeId = Long.valueOf(map.get("auxtypeId").toString());
        return AjaxResult.success(KtserviceViphallAuxtypeService.selectKtserviceViphallAuxtypeById(auxtypeId));
    }

    /**
     * 新增贵宾厅设施功能*/
    //@PreAuthorize(hasPermi = "service:auxtype:add")
    @Log(title = "贵宾厅设施功能", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody KtserviceViphallAuxtype KtserviceViphallAuxtype)
    {
        return toAjax(KtserviceViphallAuxtypeService.insertKtserviceViphallAuxtype(KtserviceViphallAuxtype));
    }

    /**
     * 修改贵宾厅设施功能*/
    //@PreAuthorize(hasPermi = "service:auxtype:edit")
    @Log(title = "贵宾厅设施功能", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody KtserviceViphallAuxtype KtserviceViphallAuxtype)
    {
        return toAjax(KtserviceViphallAuxtypeService.updateKtserviceViphallAuxtype(KtserviceViphallAuxtype));
    }

    /**
     * 删除贵宾厅设施功能*/
    //@PreAuthorize(hasPermi = "service:auxtype:remove")
    @Log(title = "贵宾厅设施功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{auxtypeIds}")
    public AjaxResult remove(@PathVariable Long[] auxtypeIds)
    {
        return toAjax(KtserviceViphallAuxtypeService.deleteKtserviceViphallAuxtypeByIds(auxtypeIds));
    }

    /**
     * 删除贵宾厅设施功能
     * */
    @PostMapping("/delRemove")
    public AjaxResult delRemove(@RequestBody Map<String, Object> map) {
        Long auxtypeId = Long.valueOf(map.get("auxtypeId").toString());
        int i = KtserviceViphallAuxtypeService.deleteKtserviceViphallAuxtypeById(auxtypeId);
        if (i > 0){
            return AjaxResult.success("删除成功");
        }
        else {
            return AjaxResult.error("删除失败");
        }
    }

    /**
     * 服务设施排序号升序操作
     * @param auxtypeId
     * @return
     */
    @GetMapping("/updateSort")
    public AjaxResult updateKtserviceViphallAuxtypeBySort(Long auxtypeId){
        return AjaxResult.success(KtserviceViphallAuxtypeService.updateKtserviceViphallAuxtypeBySort(auxtypeId));
    }

    /**
     * 服务设施排序号降序操作
     * @param auxtypeId
     * @return
     */
    @GetMapping("/updateSorts")
    public AjaxResult updateKtserviceViphallAuxtypeBySorts(Long auxtypeId){
        return AjaxResult.success(KtserviceViphallAuxtypeService.updateKtserviceViphallAuxtypeBySorts(auxtypeId));
    }

    /**
     * 服务类型下拉框
     * @param KtserviceViphallAuxtype
     * @return
     */
    @GetMapping("/serviceTypeList")
    public TableDataInfo selectKtserviceViphallAuxtypeByServiceType(KtserviceViphallAuxtype KtserviceViphallAuxtype) {
        startPage();
        List<KtserviceViphallAuxtype> list = KtserviceViphallAuxtypeService.selectKtserviceViphallAuxtypeByServiceType(KtserviceViphallAuxtype);
        return getDataTable(list);
    }

    /**
     * 弹窗列表
     * */
    @PostMapping("/selectViphallAuxtype")
    public TableDataInfo selectViphallAuxtype(@RequestBody Map<String, Object> map){
        startPage();
        String name = null;
        if (map.get("name") != null && !map.get("name").equals("")){
            name = map.get("name").toString();
        }
        List<KtserviceViphallAuxtype> list = KtserviceViphallAuxtypeService.selectViphallAuxtypeByName(name);
        return getDataTable(list);
    }
}
